package gui;

import gui.common.msg.SysMessage;

import java.awt.Toolkit;
import java.awt.Window;

import javax.swing.JOptionPane;


public class GuiCommon {

	public final static int MAIN_WINDOW_HEIGHT=480;
	public final static int MAIN_WINDOW_WIDTH=640;
	
	public static void setWindowSize(Window t,int width1,int height1){
		t.setSize(width1,height1);
		double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
        t.setLocation((int) (width - t.getWidth()) / 2, (int) (height - t.getHeight()) / 2);
	}
	
	public static  int showAlertWindow(SysMessage msg){
		int result=0;
		if(msg!=null){
			int type=JOptionPane.INFORMATION_MESSAGE;
			switch (msg.type) {
			case Error:
				type=JOptionPane.ERROR_MESSAGE;
				break;
			case Success:
				type=JOptionPane.INFORMATION_MESSAGE;
				break;
			case Warning:
				type=JOptionPane.WARNING_MESSAGE;
				break;
			case Question:
				type=JOptionPane.QUESTION_MESSAGE;
				break;
			default:
				type=JOptionPane.INFORMATION_MESSAGE;
				break;
			}
			result=JOptionPane.showOptionDialog(null, msg.detail, msg.subject,
                    JOptionPane.DEFAULT_OPTION,
                    type, null, null, null);
		}
		return result;
		
	}
}
